//@author A0100617W

#pragma once
#ifndef DATEPARSER_H                  
#define DATEPARSER_H
#include <string>
#include <regex>
#include <sstream>
#include "CurrentTime.h"


//@author A0100617W
const std::regex ddmm("(?:(?:[0-9][0-9]|0?[1-9])[\\.\\/](?:(?:[0-9][0-9])|(?:[0-9])|[F|f]eb(?:ruary)?)|(?:[0-9][0-9]|0?[1-9])[\\.\\/](?:(?:[0-9][0-9])|(?:[0-9])|(?:[0-9][0-9])|[A|a]pr(?:il)?|[J|j]une?|[S|s]ep(?:tember)?|[N|n]ov(?:ember)?)|(?:[0-9][0-9]|0?[1-9])[\\.\\/](?:(?:[0-9][0-9])|(?:[0-9])|[J|j]an(?:uary)?|[M|m]ar(?:ch)?|[M|m]ay|[J|j]uly?|[A|a]ug(?:ust)?|[O|o]ct(?:ober)?|[D|d]ec(?:ember)?))");
const std::regex ddmmyyyy("(?:(?:[0-9][0-9])|(?:[0-9]))[\\.\\/](?:[0-9][0-9]|(?:[0-9]))[\\.\\/](?:[0-9][0-9][0-9][0-9])");
const std::regex ddmmyy("(?:(?:[0-9][0-9])|(?:[0-9]))[\\.\\/](?:[0-9][0-9]|(?:[0-9]))[\\.\\/](?:[0-9][0-9])");
const std::regex mmdd("(?:[F|f]eb(?:ruary)?)[\\s]*[\\.\\-\\/]?(?:[0-9][0-9]|0?[1-9])|(?:[A|a]pr(?:il)?|[J|j]une?|[S|s]ep(?:tember)?|[N|n]ov(?:ember)?)[\\s]*[\\.\\-\\/]?(?:[0-9][0-9]|0?[1-9])|(?:[J|j]an(?:uary)?|[M|m]ar(?:ch)?|[M|m]ay|[J|j]uly?|[A|a]ug(?:ust)?|[O|o]ct(?:ober)?|[D|d]ec(?:ember)?)[\\s]*[\\.\\-\\/]?(?:[0-9][0-9]|0?[1-9])");
const std::regex weekday("([M|m]on(?:day)?|[T|t]ue(?:sday)?|[W|w]ed(?:nesday)?|[T|t]hu(?:rsday)?|[F|f]ri(?:day)?|[S|s]at(?:urday)?|[S|s]un(?:day)?)[\\s|.|,|!|?|;|)|(|:|'|<|>|]");
const std::regex nextWeekday("(?:[N|n]ext)[\\s]*?(?:(?:[M|m]on(?:day)?)|[T|t]ue(?:sday)?|[W|w]ed(?:nesday)?|[T|t]hu(?:rsday)?|[F|f]ri(?:day)?|[S|s]at(?:urday)?|[S|s]un(?:day)?)[\\s|.|,|!|?|;|)|(|:|'|<|>|]");
const std::regex tmr("((?:[T|t][M|m][R|r])|(?:[T|t][O|o][M|m][O|o][R|r][R|r][O|o][W|w])|(?:[T|t][O|o][M|m])|(?:[T|t][O|o][M|m][O|o]))");
const std::regex today("(?:[T|t][O|o][D|d](?:[A|a][Y|y])?)");
const std::regex wrongDate("[\\d][\\d]?[\\.\\-\\/][\\d][\\d]?");

const std:: string NOT_FOUND_STRING_2 = " \",./?';:][{}\\|<>=+-_)(*&^%$#@!~`";
const std:: string QUOTE_DATE="";
const std:: string ZERO_STRING_DATEPARSER = "0";
const std:: string MINOR_DATEPARSER="-";
const std:: string NUMBER_STRING_DATEPARSER="0123456789";

const std:: string ZERO_ONE_DATEPARSER="01";
const std:: string ZERO_TWO_DATEPARSER="02";
const std:: string ZERO_THREE_DATEPARSER="03";
const std:: string ZERO_FOUR_DATEPARSER="04";
const std:: string ZERO_FIVE_DATEPARSER="05";
const std:: string ZERO_SIX_DATEPARSER="06";
const std:: string ZERO_SEVEN_DATEPARSER="07";
const std:: string ZERO_EIGHT_DATEPARSER = "08";
const std:: string ZERO_NINE_DATEPARSER = "09";
const std:: string TEN_DATEPARSER = "10";
const std:: string ELEVEN_DATEPARSER = "11";
const std:: string TWELVE_DATEPARSER = "12";
const std:: string TWENTY_DATEPARSER = "20";



//@author A0100617W
class DateParser
{
private:
	
	
	std::string clear_Space_Punctuation(std::string);
	int weekdayToNum(std::string);
	bool isLeapyear(int);
	std::string correctDate(std::string);
	std::string getStandardDateString_mm_dd(std::string);
	std::string getStandardDateString_dd_mm_yyyy(std::string);
	std::string getStandardDateString_dd_mm_yy(std::string);
	std::string getStandardDateString_dd_mm(std::string);
	std::string getStandardDateString_next_weekday(std::string);
	std::string getStandardDateString_weekday(std::string);
	std::string getStandardDateString_tmr();
	std::string getStandardDateString_today();

public:
	DateParser();
	~DateParser(void);
	bool parse(std::string, std::string&, size_t&, size_t&);

};


#endif
//check wrong date